package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.dao.StudentDao;
import com.sys.entity.Student;
import com.sys.service.StudentService;

@Service
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentDao StudentDao;

	@Override
	public Map<String, Object> getAllStudent(String sname, String phone, Integer del, Integer page, Integer limit) {
		Map<String, Object> prams = new HashMap<String, Object>();
		prams.put("sname", sname);
		prams.put("phone", phone);
		prams.put("del", del);
		page = (page - 1) * limit;
		prams.put("page", page);
		prams.put("limit", limit);
		List<Student> list = StudentDao.getAllStudent(prams);
		int total = StudentDao.getAllStudentCount(prams);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}

	@Override
	public int addStudent(Student student) {
		int len=StudentDao.addStudent(student);
		return len;
	}

	@Override
	public int updateStudent(Student student) {
		int len=StudentDao.updateStudent(student);
		return len;
	}

	@Override
	public int deleteStudent(Student student) {
		int len=StudentDao.deleteStudent(student);
		return len;
	}

}
